﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IO = System.IO;
using System.Windows;
using System.Windows.Threading;
using System.Xml.Serialization;
using System.IO.Compression;
using System.Text.RegularExpressions;

namespace SLP
{
    public static class StringExtensions
    {
        /// <summary>
        /// Allows for Wild Card string matching
        /// </summary>
        /// <param name="Text">String to be checked</param>
        /// <param name="pattern">Pattern or mask to be checked against</param>
        /// <param name="IsCaseSensitive">Is this match Case Sensitive?</param>
        /// <returns></returns>
        public static bool IsLike(this string Text, string pattern, bool IsCaseSensitive = false)
        {
            pattern = pattern.Replace(".", @"\.").Replace("?", ".").Replace("*", ".*?").Replace(@"\", @"\\").Replace(" ", @"\s");
            return new Regex(pattern, IsCaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase).IsMatch(Text);
        }
    }
}
